#include <iom8v.h>
#include <macros.h>

#define SetBit(x,y) (x|=(1<<y)) 
#define ClrBit(x,y) (x&=~(1<<y)) 

/* This seems to produce the right amount of delay for the LED to be
 * seen
 */
void Delay()
	{
	unsigned char a, b;

	for (a = 1; a; a++)
		for (b = 1; b; b++)
			;
	}
void DelayS()
	{
	unsigned char a;

	for (a = 1; a; a++)
			;
	}

void LED_On(int i)
	{
	PORTB = ~BIT(i);	/* low output to turn LED on */
	Delay();
	Delay();
	Delay();
	}

	
void LED_Control(unsigned char i,unsigned char j)
{
	unsigned char a, b;

	for (b = 1; b<50; b++)
	{
	for (a = 1; a<100; a++)
	{
	 if(a>i) ClrBit(PORTB,0);
	 else	 SetBit(PORTB,0);
	 if(a>j) ClrBit(PORTB,1);
	 else	 SetBit(PORTB,1);
	}
	}
 	 
}
void main()
	{
	unsigned char i,j;
	DDRB = 0xFF;	/* output */
	PORTB = 0xFF;	/* all off */

	while (1)
		{
		//SetBit(PORTB,0);
	 	//ClrBit(PORTB,1);
		/* forward march */		
		for (i = 0; i<20 ; i++)
			for (j = 0; j<10 ; j++)
				LED_Control(i*5,j*5);
		

		}
	}
